<?php

namespace app\admin\model;

use think\Model;


class Grade extends Model
{

    

    

    // 表名
    protected $name = 'grade';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_data_text'
    ];
    

    
    public function getTypeDataList()
    {
        return ['1' => __('Type_data 1'), '2' => __('Type_data 2'), '3' => __('Type_data 3'), '4' => __('Type_data 4')];
    }


    public function getTypeDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type_data']) ? $data['type_data'] : '');
        $list = $this->getTypeDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function school()
    {
        return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
